package com.ly.test;

import com.ly.entity.Student;
import com.ly.util.JedisUtil;

import java.util.Scanner;

/**
 * @author 李岩
 * @date 2021/12/16-13:40
 * @describe
 */
public class redistest {
    public static void main(String[] args) {
        System.out.println("测试");
        JedisUtil jedisUtil = new JedisUtil();
        Scanner sc = new Scanner(System.in);


        System.out.println("请输入选择班级");
        String name1=sc.next();
        for (int i = 0; i < 3; i++) {
            Student stu = new Student();
            System.out.println("请输入学生姓名");
            stu.setSname(sc.next());
            System.out.println("请输入学生年龄");
            stu.setSage(sc.nextInt());
            Student stu1 = jedisUtil.setStu(stu);
            jedisUtil.setclass(name1,stu1);
        }
        System.out.println("请输入选择班级");
        String name2=sc.next();
        for (int i = 0; i < 3; i++) {
            Student stu = new Student();
            System.out.println("请输入二班的学生姓名");
            stu.setSname(sc.next());
            System.out.println("请输入二班的学生年龄");
            stu.setSage(sc.nextInt());
            Student stu2 = jedisUtil.setStu(stu);
            jedisUtil.setclass(name2,stu2);
        }
        System.out.println(name1+"的班级有哪些学生");
        for (String s : jedisUtil.findAllStudentBySet(name1)) {
            System.out.println(s);
        }
        System.out.println(name2+"的班级有哪些学生");
        for (String s : jedisUtil.findAllStudentBySet(name2)) {
            System.out.println(s);
        }


    }
}
